<?php
	session_start();	
?>

<?php
	if( $_SESSION["admin"] != "" )
	{
?>
<a href="index.php?com=capbac"><b>List rank</b></a> | <a href="index.php?com=capbac&func=add"><b>Add rank</b></a>
<?php
	include_once("process/capbac.php");	
	$capbac = new capbac();
	
	if( $_GET["com"] == "capbac" && $_GET["func"] == "update" && isset($_GET["id"]))
	{
		$row = $capbac->GetOneCapbac($_GET['id']);	
	}elseif( isset($_POST['btnUpdate']) )
	{	
			$name=stripcslashes($_POST["capbac_name"]);
			$value=stripcslashes($_POST["value"]);
            $id = stripcslashes($_POST["capbac_id"]);
            
			$capbac->UpdateCapbac($id, $name, $value);
			
			echo '<meta http-equiv="Refresh" content="0;URL=index.php?com=capbac" />';
	}
	else
	{
		echo '<meta http-equiv="Refresh" content="0;URL=index.php?com=capbac" />';
	}	
	
?>
<form action="index.php?com=capbac&func=update" method="post" id="contactform">
	<table width="630px" style="font-weight:bold; font-size:10pt;" border="0">
		<tr>
			<td align="center" colspan="4" height="50"><b style="font-size:12pt; color:Blue;">Update capbac</b></td>
		</tr>
		<tr>
			<td align="right" width="120px">Name :&nbsp;&nbsp;
				<input type="hidden" name="capbac_id" id="capbac_id" value="<?php echo $row['capbac_id'] ?>" />
			</td>
			<td width="140px"><input type="text" class="validate[required]" name="capbac_name" id="capbac_name" value="<?php echo $row['capbac_name']; ?>" style="width: 120px;" /><font style="color: red;"> *</font>
				<input type="hidden" name="capbac_id" id="capbac_id" value="<?php echo $row['capbac_id'] ?>" />
			</td>
        </tr>
        <tr>
			<td align="right" width="120px">Value :&nbsp;&nbsp;</td>
			<td><input type="text" name="value" class="validate[required]" id="value" value="<?php echo $row['value']; ?>" style="width: 120px;" /><font style="color: red;"> *</font></td>
		</tr>  	    
		<tr>
			<td></td>
			<td colspan="3" height="40">
				<input type="submit" name="btnUpdate" id="btnUpdate" value="Update" />
				<input type="reset" value="Reset" />
			</td>
		</tr>
    </table>
</form><br><br>
<i>Please fill in these fields (<font style="color: red;">*</font>)</i>
<?php
     }
   else
	{
		echo "<meta http-equiv='refresh' content='0; url=login.php' />";
	}
?>